package com.mck.mapper;

import com.mck.entity.Classname;
import com.mck.entity.UserClassname;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author : mck
 * @Date : 2025/2/24 12:18
 */
@Mapper
public interface UserClassnameMapper {

    /**
     * 获取user和classname关联列表
     */
    @Select("select * from user_classname")
    List<UserClassname> getUserClassnameList();


    /**
     * 添加user和classname关联
     */
    // @Insert("insert into user_classname(user_id, class_id, user_type_id) values (#{userId}, #{classId}, #{userTypeId})")
    void addUserClassname(List<UserClassname> userClassname);

    /**
     * 根据classId获取user列表
     */
    @Select("select * from user_classname where class_id = #{classId} and user_type_id = #{userTypeId}")
    List<UserClassname> getUserListByClassId(Integer classId, Integer userTypeId);

    /**
     * 根据userId获取classname列表
     */
    @Select("select * from user_classname where user_id = #{userId}")
    List<UserClassname> getClassnameListByUserId(Integer userId);

    /**
     * 删除user和classname关联
     */
    @Delete("delete from user_classname where user_id = #{userId}")
    void deleteUserClassnameByUserId(Integer userId);
}
